import { userAccountLogin } from '@/api/user.js'
const user = {
  namespaced: true,
  state: () => ({
    profile: {
    }
  }),
  mutations: {
    setProfile (state, profile) {
      state.profile = profile
    },
    clearProfile (state) {
      state.profile = {}
    }
  },
  actions: {
    // 登录
    // 1.调接口
    async login (ctx, { account, password }) {
      const res = await userAccountLogin({ account, password })
      console.log(res)
      ctx.commit('setProfile', res.result)
      // 为什么不把跳转写在这里
      // 因为vuex封装和‘数据状态’相关的操作不妨至其他业务逻辑
    }
  },
  getters: {}
}

export default user
